﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESBasic;
using OMCS.Passive;

namespace Chat.Forms
{
    public partial class WhiteBoardForm : Form
    {
        private string ownerID;

        public WhiteBoardForm(string _owerID)
        {
            InitializeComponent();
            this.whiteBoardConnector1.WatchingOnly = false;

            this.ownerID = _owerID;
            this.Text = string.Format("正在访问{0}的电子白板", this.ownerID);
            this.whiteBoardConnector1.ConnectEnded += new CbGeneric<ConnectResult>(whiteBoardConnector1_ConnectEnded);
            this.whiteBoardConnector1.BeginConnect(this.ownerID);
        }

        void whiteBoardConnector1_ConnectEnded(ConnectResult result)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new CbGeneric<ConnectResult>(this.whiteBoardConnector1_ConnectEnded), result);
            }
            else
            {
                if (result != ConnectResult.Succeed)
                {
                    MessageBox.Show("连接失败" + result.ToString());
                }
                else
                {
                }
            }
        }

        private void WhiteBoardForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.whiteBoardConnector1.Disconnect();
            this.whiteBoardConnector1.Dispose();
        }
    }
}
